package com.lightjet.macross.base.gateway.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class GateWayConfig {
    @Bean
    public RouteLocator DevelopLocator( @Autowired RouteLocatorBuilder builder)
    {
        return builder.routes()
                .route(r-> r.path("/biz-palms/process/**")
                        .filters(f-> f.stripPrefix(1) ).uri("http://10.122.165.25:8907/").order(0))
                .route(r-> r.remoteAddr("10.122.165.20")
                        .and().path("/biz-palms/**")
                            .filters(f-> f.stripPrefix(1) ).uri("http://10.122.165.20:8907/"))
                .route(r-> r.remoteAddr("10.122.165.25").
                        and().path("/biz-palms/**")
                            .filters(f-> f.stripPrefix(1) ).uri("http://10.122.165.25:8907/"))
                .route(r-> r.remoteAddr("10.122.165.32").
                        and().path("/biz-palms/**")
                        .filters(f-> f.stripPrefix(1) ).uri("http://10.122.165.32:8907/"))
                .route(r-> r.remoteAddr("10.122.165.54")
                        .and().path("/biz-mes/**")
                        .filters(f-> f.stripPrefix(1) ).uri("http://10.122.165.54:8901/"))
                .route(r-> r.remoteAddr("10.122.165.20")
                        .and().path("/biz-mes/**")
                        .filters(f-> f.stripPrefix(1) ).uri("http://10.122.165.20:8901/"))
                .build();
    }
}
